package de.medieninf.webanw;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;




public class FrontController extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String seite_one = "/JSPs/rechner.jsp";
		String seite_two = "/JSPs/einstellung.jsp";
		
		ServletContext sc = this.getServletContext();
		HttpSession session = (HttpSession) request.getSession(true);
		
		if (session.getAttribute("rechnerBean") == null){
			RechnerBean rechnerBean = new RechnerBean();
			session.setAttribute("rechnerBean", rechnerBean);
		}
		
		
		String seite = request.getParameter("seite");
		//sc.log("XXXXXXXXXXXXXXXXXXXX"+seite);
		
		if(seite != null){
			if(seite.equals("rechner")){
//				request.getParameter("grundwaehrung");
//				request.getParameter("zielwaehrung");
				RequestDispatcher rd = request.getRequestDispatcher(seite_one);
				rd.forward(request,response);
			}
			if(seite.equals("einstellung")){
				RequestDispatcher rd = request.getRequestDispatcher(seite_two);
				rd.forward(request,response);
			}
		}else{
			RequestDispatcher rd = request.getRequestDispatcher(seite_one);
			rd.forward(request,response);
		}
		
		
	}

}
